<template>
  <div>
    <!-- 搜索历史组件 -->
    <van-cell title="搜索历史">
      <template #right-icon>
        <div v-if="showDelBtn">
          <van-button
            color="linear-gradient(to right, #4bb0ff, #6149f6)"
            size="mini"
            @click="$emit('del-histories')"
          >删除全部</van-button>
          <van-button
            color="linear-gradient(to right, #4bb0ff, #6149f6)"
            size="mini"
            @click="showDelBtn=false"
          >完成</van-button>
        </div>
        <van-icon v-else name="delete" @click="showDelBtn=true" />
      </template>
    </van-cell>
    <van-cell
      :title="item"
      v-for="(item,index) in searchHistorios"
      :key="index"
      @click="showDelBtn==true?$emit('del-histories',index):''"
    >
      <template #right-icon>
        <van-icon name="close" v-show="showDelBtn" />
      </template>
    </van-cell>
  </div>
</template>

<script>
export default {
  props: {
    searchHistorios: {
      required: true,
      type: Array
    }
  },
  data() {
    return {
      showDelBtn: false
    }
  },
  methods: {}
}
</script>

<style lang='less' scoped></style>
